<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>专业化评价预警工具 - 登录/注册/忘记密码</title>
    <style>
        /* 保留原有的样式 */
        .container {
            background-color: white;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            position: relative;
            overflow: hidden;
        }
        .container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background-color: #2a9d8f;
        }
        .container::after {
            content: '';
            position: absolute;
            top: -50px;
            right: -50px;
            width: 100px;
            height: 100px;
            background-color: rgba(42, 157, 143, 0.1);
            border-radius: 50%;
        }
        h1 {
            color: #333;
            margin-bottom: 1.5rem;
            font-size: 1.75rem;
            text-align: center;
        }
        .input-group {
            margin-bottom: 1.25rem;
            position: relative;
        }
        label {
            display: block;
            margin-bottom: 0.5rem;
            color: #555;
            font-size: 0.9rem;
        }
        input[type="text"],
        input[type="password"],
        input[type="email"] {
            width: 100%;
            padding: 0.75rem;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 1rem;
            transition: border-color 0.3s, box-shadow 0.3s;
        }
        input[type="text"]:focus,
        input[type="password"]:focus,
        input[type="email"]:focus {
            outline: none;
            border-color: #2a9d8f;
            box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.2);
        }
        .form-switch {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            font-size: 0.9rem;
        }
        .form-switch a {
            color: #2a9d8f;
            text-decoration: none;
            transition: color 0.3s;
        }
        .form-switch a:hover {
            color: #238b7e;
            text-decoration: underline;
        }
        .submit-button {
            width: 100%;
            padding: 0.75rem;
            background-color: #2a9d8f;
            color: white;
            border: none;
            border-radius: 4px;
            font-size: 1rem;
            cursor: pointer;
            transition: background-color 0.3s, transform 0.1s;
        }
        .submit-button:hover {
            background-color: #238b7e;
        }
        .submit-button:active {
            transform: translateY(1px);
        }
        .system-info {
            margin-top: 2rem;
            padding-top: 1rem;
            border-top: 1px solid #eee;
            text-align: center;
            color: #777;
            font-size: 0.875rem;
        }
        @media (max-width: 480px) {
            .container {
                padding: 1.5rem;
            }
            h1 {
                font-size: 1.5rem;
            }
        }
        .hidden {
            display: none;
        }
        .delete-button {
            background-color: #e63946;
        }
        .delete-button:hover {
            background-color: #d62828;
        }
        .v-modal{
            z-index: 0 !important;
        }
    </style>
</head>
<body>
<div id="del_div2" style="display: none">
    <div id="del_div" style="position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);">
        <div class="container" style="height: 450px">
            <!-- 新增：删除用户表单 -->
            <div id="deleteUserForm">
                <h1>专业化评价预警工具 - 删除用户</h1>
                <form @submit.prevent="submit">
<!--                    <div class="input-group">-->
<!--                        <label for="deleteUsername">用户名</label>-->
<!--                        <input type="text" id="deleteUsername" name="username" placeholder="请输入管理员用户" required>-->
<!--                    </div>-->
<!--                    <div class="input-group">-->
<!--                        <label for="deletePassword">密码</label>-->
<!--                        <input type="password" id="deletePassword" name="password" placeholder="请输入密码" required>-->
<!--                    </div>-->
<!--                    <div class="input-group">-->
<!--                        <label for="deleteConfirmPassword">确认密码</label>-->
<!--                        <input type="password" id="deleteConfirmPassword" name="confirmPassword" placeholder="请再次输入密码" required>-->
<!--                    </div>-->
                    <div class="input-group" style="display: flex;flex-direction: column">
                        <label for="deleteConfirmPassword">删除的用户名</label>
                        <!--                    <input type="text" id="delusername" name="confirmPassword" placeholder="请输入要删除的用户名" required>-->
                        <el-select v-model="delusername" placeholder="请选择">
                            <el-option
                                    v-for="item in options"
                                    :key="item.create_time"
                                    :label="item.name"
                                    :value="item.name">
                            </el-option>
                        </el-select>
                    </div>

                    <div class="form-switch">
                        <a href="#" onclick="showLoginForm()">返回首页</a>
                    </div>
                    <button type="submit" class="submit-button delete-button">删除用户</button>
                </form>
            </div>
            <div class="system-info">
                专业化评价预警工具
            </div>
        </div>
        <el-dialog
                :visible.sync="dialogVisible"
                width="100%"
                :before-close="handleClose">
            <span>确认要删除{{delusername}}用户吗？此操作不可逆</span>
            <span></span>
            <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="submit2()">确 定</el-button>
  </span>
        </el-dialog>
    </div>
</div>
<script src="${ROOT}/mind/js/vue2.js"></script>
<link href="${ROOT}/mind/css/element-ui.css" rel="stylesheet">
<!-- 引入Element Plus的JavaScript -->
<script src="${ROOT}/mind/js/element-ui.js"></script>
<script>
    new Vue({
        el: '#del_div',
        data() {
            return {
                dialogVisible: false,
                options: [],
                delusername: [],
            };
        },
        mounted(){
            this.get_list()
        },
        methods:{
            get_list(){
                let url = 'http://127.0.0.1:8001/ul?u=admin&p=admin'
                fetch(url)
                    .then(response => response.json())
                    .then(data => {
                        this.options = data.data
                    })
            },
            handleClose(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {});
            },
            submit(){
                this.dialogVisible = true
            },
            submit2(){
                this.dialogVisible = false
                let username = sessionStorage.getItem('userName');
                console.log(username,'username0=-0-=')
                let password = sessionStorage.getItem('password');
                console.log(password,'password0-=0-==')
                // let confirmPassword = document.getElementById('deleteConfirmPassword').value;

                if(!this.delusername) {
                    this.$message({
                        message: '请选择要删除的用户',
                        type: 'error'
                    });
                } else {
                    let url = 'http://127.0.0.1:8001/delu?u=' + username + '&p=' + password + '&du=' + this.delusername;
                    fetch(url)
                        .then(response => response.json())
                        .then(data => {
                            if (data.code == 0) {
                                this.$message({
                                    message: '用户删除成功',
                                    type: 'success'
                                });
                                document.getElementById('loginDiv').style.display = 'none'
                                this.get_list()
                                this.delusername = ''
                            }else if(data.code == 3) {
                                this.$message({
                                    message: '数据库错误',
                                    type: 'error'
                                });
                            } else {
                                this.$message({
                                    message: '未知错误',
                                    type: 'error'
                                });
                            }
                        })
                    // .catch(error => {
                    //     alert('删除用户请求出错，请稍后再试');
                    // });
                }
            }
        }
    })
    function  showLoginForm(){
        document.getElementById('loginDiv').style.display = 'none'
    }
    // 新增：删除用户的事件监听器
</script>
</body>
</html>